home *** CD-ROM | disk | FTP | other *** search
/ Peanuts 2 / Peanuts - Issue 2 (Alcatraz).adf / stc401.doc < prev   
Text File  |  2005-03-27  |  13KB  |  350 lines

  1.  
  2.  
  3.     StoneCracker v4.01 - Command and Data File Cruncher
  4.  
  5.  
  6.  
  7.     Written and developed by Jouni 'Mr.Spiv' Korhonen. I am 20 years old
  8.     _poor_ student from cold Finland. I study mathematics (and computer
  9.     science) in Helsinki University and every now and then waste a bit
  10.     of my spare time programming programs like StoneCracker.
  11.  
  12.     This program is PD, freeware or what ever you want to call it and it
  13.     may be copied and used freely. But StoneCracker is NOT allowed to be
  14.     sold or used for any commercial purposes without my permission.
  15.  
  16.     To contact me write to:        PL 176
  17.                     11101 Riihimaki
  18.                     Finland
  19.  
  20.     This will just be a brief overview of this cruncher utility. If you
  21.     can use such programs like PowerPacker or Imploder you can also use
  22.     the fabulous StoneCracker too.
  23.  
  24.  
  25.  
  26.     First I will write down all the things StoneCracker v4.01 can do...
  27.  
  28.     · There are three different filetypes that can be crunched with
  29.     StoneCracker: command files (=normal executable files), pure data
  30.     and absolute memory address located files.
  31.  
  32.     · Command file cruncher can support standard hunk structures with
  33.     hunk_code, hunk_data, hunk_bss and hunk_reloc32. Hunk_debug and
  34.     hunk_symbol are removed when found. Note that StoneCracker refuses
  35.     to crunch programs which can not be relocated correctly after
  36.     decrunching process e.g programs with strange hunk structure, not
  37.     supported hunk type or overlayed files.
  38.  
  39.     · Data files are crunched and saved as raw data. Only the decruncher
  40.     infoheader is added to the saved file. The form of the infoheader is:
  41.     DC.B "S401"    ;the file was crunched with S401 algorithm
  42.     DC.L $000000    ;original file length
  43.     DC.L $000000    ;crunched file length
  44.     There is a sourcecode for the data decruncher at the end of this file.
  45.  
  46.     · Absolute memory address located files are crunched as raw data so
  47.     you can not relocate any command files to absolute memory addresses.
  48.     Before saving the crunched file you are asked for some information
  49.     for the decruncher:
  50.     Load address - Locate your decrunched program here
  51.     High address - End of the memory area the decruncher may change or
  52.                corrupt while decrunching
  53.     Jump address - After decrunching jump here (start your program)
  54.     Decruncher   - Place the decruncher code here (needs 230 bytes)
  55.     DmaCon       - Set or mask the dmacon ($dff096) bits before
  56.                decrunching ($0 for no action)
  57.     IntEna       - Set or mask the interrupt enable ($dff09a) bits
  58.                before decrunching ($0 for no action)
  59.     System Stack - Relocate SSP (supervisor or exception stackpointer).
  60.                When this field is non zero (<>$0) the value is moved
  61.                to SSP and processor turned to SuperVisor mode (I use
  62.                illegal instruction vector (at $0010.w) and command
  63.                Illegal). You better turn interrupts off when you
  64.                relocate the SSP.
  65.     Accept       - Accept all values and save the file with a decruncher.
  66.     Notice that stacks are not used during decrunch process. If you change
  67.     dmacon or intena remember that decruncher does not restore original
  68.     values. Be careful with this filetype.
  69.  
  70.     · BE CAREFUL WITH ODD VALUES! Decrunchers do not like odd values! It
  71.     is not a problem with data decruncher since you can take care of the
  72.     code yourself. But absolute address decruncher will crash!
  73.  
  74.     · StoneCracker checks automatically if the file you want to crunch, is
  75.     already crunched with StoneCracker. All the three file types can be
  76.     decrunched and saved in their original form.
  77.  
  78.     · When there is a crunched or decrunched file in buffer and you have
  79.     not saved the file yet, you can see a '*'-character as a sign of that
  80.     in the menubar. After saving the file the sign will disappear. When
  81.     quiting or going to sleep StoneCracker shows a requester if there is
  82.     a file in buffer which is not saved yet.
  83.  
  84.     · Crunched data or absolute files can also be saved to tracks. Nice
  85.     option for programs that use trackdisk. Data files are tracked in the
  86.     same format as a normal data file. Absolute files are tracked with the
  87.     decruncher header but not with the hunk stuff in front of a normal
  88.     absolute file (tracked file is 36 bytes shorter).
  89.  
  90.     · Delete files is useful when you need to kill some diskspace
  91.     consuming files from your disks.
  92.  
  93.     · Sleep - This will free all allocated buffers, close windows, screens
  94.     and generally everything that StoneCracker needs. Only a little sleep
  95.     window appears to your WorkBench screen. You can run StoneCracker
  96.     again by pressing the right mousebutton on an activated sleep window.
  97.  
  98.     · File type - Select which type files you want to crunch. Note that if
  99.     you change file type before saving the crunched file it will not
  100.     affect the file which is already in buffer waiting for saving. Default
  101.     is set to command file type.
  102.  
  103.     · Decrunch color - Which color will flash ('Let there be light!')
  104.     during decrunch process. Default is set to no flashing.
  105.  
  106.     · Show buffer info gives you some statistics about the buffer's
  107.     contents. Whether it is empty or is the file in the buffer crunched
  108.     or decrunched and which file type.
  109.  
  110.     · Then there are several settings for hunklab. Note that they affect
  111.     only to command files when files are loaded into the buffer.
  112.     Remove Hunk_symbol - Loaded command file is scanned and if any
  113.                  Hunk_symbols are found they are removed from the
  114.                  file. Default setting is remove all Hunk_symbols.
  115.     Remove Hunk_debug  - Same things to Hunk_debug as above. Note that the
  116.                  decruncher can not relocate programs that have
  117.                  Hunk_debugs or Hunk_symbols.
  118.     Hunk_code to Chip  - Force all found Hunk_codes to be loaded into Chip
  119.                  memory.
  120.     Hunk_data to Chip  - Same as above for all Hunk_datas.
  121.     Hunk_bss to Chip   - Same as above for all Hunk_bsses.
  122.  
  123.     Well, I started developing this cruncher utility in November -91. I
  124.     was inspirated by the article of LZRW1 algorithm developed by the
  125.     dynamic duo ZIV-Lempel. Because this algorithm was really _fast_ I
  126.     made some testing with it. I was disappointed of the poor efficiency
  127.     and rewrote the algorithm using other methods to save crunched data.
  128.     The efficieny got heaps better but at the same time I lost most of
  129.     the speed. So the only thing what is left from the original algorithm
  130.     is the search funtion, everything else is developed and written by me.
  131.     A pity the algorithm still has poor efficiency but the crunching time
  132.     is _short_ - for example DPaint IV takes only 20 seconds! In average
  133.     StoneCracker is about _18_ (yes!) times _faster_ than PowerPacker.
  134.  
  135.     A demoversion of StoneCracker (v4.00) got spread around and later I
  136.     thought it was a misstake. I should not have allowed it to happen and
  137.     consentrate more on v4.01. You know v4.00 was very plain. But now on
  138.     it is quite sure that I will not develope StoneCracker very much. Bug
  139.     fixes will be released when needed, maybe a better hunklab and turbo
  140.     mode (based almost directly on LZRW1). Anyway now I have finished my
  141.     research with crunching algorithms and reached what I wanted to - to
  142.     program a _fast_ and useful cruncher for my own purposes. I have
  143.     noticed that the only thing to develope (only worth developing) is
  144.     the user interface and it has nothing to do with algorithms so...
  145.     Now it is time to find a new district to explore! But let us continue
  146.     with the documentation...
  147.  
  148.     Decrunchers are a combination of fast and short code. Especially the
  149.     command file decruncher was developed carefully and there should not
  150.     be much to optimize anymore (erm... I could rip four bytes away). The
  151.     decruncher and relocator take only 316 bytes (ha, beat it!). Then
  152.     there are also 104 bytes long control program which calls decruncher
  153.     and afterwards frees extra memory needed by the decruncher. After
  154.     decrunching only the original and control programs will be left.
  155.  
  156.     The whole cruncher utility was written from scratch in assembly and
  157.     that is probably the reason why the program is so short (about 20Kb).
  158.     Very big thanks must go to * NICO FRANÇOIS * for the REQTOOLS which I
  159.     used for all requesters.
  160.  
  161.     StoneCracker was developed using a normal A2000c (1.3) with standard
  162.     equipment (HD, extra memory etc). The program is KickStart 2.04
  163.     compatible and works as well in A3000. Because the program is
  164.     written in assembly and my second serious attempt in 'clean' system
  165.     programming it is quite obvious that there are some bugs around.
  166.     Please let me know about all the bugs so I can fix them. Please
  167.     contact me via the address at the beginning of this file since it
  168.     will be quite hard to reach me next year using other medias (all
  169.     Finns know what I mean...).
  170.  
  171.     There is one thing that made the developement hard and slow. The lack
  172.     of literature. I have only used Includes & Autodocs and one loose
  173.     Abacus book as a reference. For example all my knowledge of Amiga's
  174.     hunks and how program is loaded into memory is based on experience.
  175.     Fortunately there are good programs around like Amiga Monitor by Timo
  176.     Rossi. I had already finished StoneCracker v4.01 when I at last found
  177.     a book that would have told me everything about hunks. I did not buy
  178.     it, yet.
  179.  
  180.     I must thank following people for their help, ideas, bug-reports and
  181.     betatesting StoneCracker: Mape alias Darxon, Hot and especially Exterm
  182.     who found a nasty bug from the command file decruncher and drawind the
  183.     StoneCracker logo. If Mape does    not stop nagging about utilities which
  184.     should support _stoned_ files, I will probably have to write some
  185.     PPmore style utilities. Next coming bigger 'Stone' utility should be
  186.     StoneSmasher - an ultimate Hunk_Tool for editing, verifying, fixing,
  187.     relocating, deleting and adding hunks to/from command files.
  188.  
  189.     I hope you find this program worth using although it is not the most
  190.     fancy and powerful cruncher around. Use Imploder... It is surely the
  191.     best! Sorry for my bad Engleesh.
  192.  
  193.     Click...
  194.  
  195.  
  196.     MOVEQ #0,D0
  197.     RTS            ;succesful exit
  198.  
  199.  
  200.  
  201.  
  202.     Now I will explain how the crunched data must be decrunched... Notice
  203.     that S401 - algorithm does not decrunch data as almost every other
  204.     algorithm around. The crunched data is read from low memory to high
  205.     memory and then the decrunched data is written from low memory to high
  206.     memory too. Like this...
  207.  
  208.     D=decrunched data, C=crunched data, M=memory area, S=security area
  209.  
  210.  
  211.                             +---- high memory
  212.                             |
  213.     +---- low memory                | +---- security area
  214.     |                        | |
  215.     MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSSSSSSSS
  216.     DDDDDDDDDDDDDDDDD...
  217.     | |                            
  218.     | +------< move decrunched data <-------CCCCCCCCCCCCCCCCC
  219.     |                    |
  220.     |                    +---- start of crunched data
  221.     +---- start of decrunched data
  222.  
  223.  
  224. ;-------------------------------------------------*
  225. ;- StoneCracker - v4.01 - Data decruncher
  226. ;-------------------------------------------------*
  227. ;
  228. ;inputs: a0=destination address
  229. ;     a2=crunched data
  230. ;output: d0=0 if decrunched ok
  231. ;     d0=-1 if not StoneCracker 'S401' data
  232. ;
  233. ;--------------    decrunch data - uses d0-d6/a0-a4
  234. lzd_decrunch:    cmp.l    #"S401",(a2)+
  235.         beq.s    lzd_trapantti_kayntiin
  236.         moveq    #-1,d0
  237.         rts
  238.  
  239. lzd_trapantti_kayntiin:
  240.         moveq    #2,d5
  241.         moveq    #15,d6
  242.  
  243.         move.l    a0,a3
  244.         add.l    (a2)+,a3        ;uncrunched length
  245.         move.l    (a2)+,d0        ;crunched length
  246. lzd_color:    lea    $dff1fe,a4
  247.  
  248.         move    (a2)+,d0
  249.         lsr    #1,d6
  250.         addx    d0,d0
  251.         bra.s    lzd_first
  252.  
  253. lzd_ympari_mennaan_yhteen_tullaan:
  254.         add    d0,d0
  255. lzd_first:    bne.s    lzd_no_ovl1
  256.         move    (a2)+,d0
  257.          move    a2,(a4)            ;'let there be light!'
  258.         addx    d0,d0
  259. lzd_no_ovl1:    bcs.s    lzd_xcopy
  260.  
  261. lzd_byte:    moveq    #0,d3
  262. lzd_loop6:    moveq    #0,d2
  263.  
  264.         moveq    #2,d4
  265. lzd_l1:        add    d0,d0
  266.         bne.s    *+6
  267.         move    (a2)+,d0
  268.         addx    d0,d0
  269.         addx    d2,d2
  270.         dbf    d4,lzd_l1
  271.  
  272.         add    d2,d3
  273.         cmp    d6,d2
  274.         beq.s    lzd_loop6
  275.  
  276. lzd_arsi_ja_kopi_kavi_taalla:
  277.         moveq    #7,d4
  278. lzd_loop7:    add    d0,d0
  279.         bne.s    *+6
  280.         move    (a2)+,d0
  281.         addx    d0,d0
  282.         addx.b    d2,d2
  283.         dbf    d4,lzd_loop7
  284.  
  285.         move.b    d2,(a0)+
  286.         dbf    d3,lzd_arsi_ja_kopi_kavi_taalla
  287.  
  288.         bra.s    lzd_test
  289.  
  290. lzd_apuuva:    dc.b    1,2,3,-1
  291.  
  292. lzd_xcopy:    moveq    #0,d2
  293.         moveq    #1,d4
  294.  
  295. lzd_l3:        add    d0,d0
  296.         bne.s    *+6
  297.         move    (a2)+,d0
  298.         addx    d0,d0
  299.         addx    d2,d2
  300.         dbf    d4,lzd_l3
  301.  
  302.         moveq    #0,d3
  303.         moveq    #0,d1
  304.         move.b    lzd_apuuva(pc,d2.w),d3
  305.         bmi.s    lzd_loop4
  306.  
  307. lzd_loop3:    add    d0,d0
  308.         bne.s    lzd_no_ovl4
  309.         move    (a2)+,d0
  310.         addx    d0,d0
  311. lzd_no_ovl4:    addx    d1,d1
  312.         dbf    d3,lzd_loop3
  313.  
  314. lzd_loop4:    moveq    #7,d4
  315. lzd_l4:        add    d0,d0
  316.         bne.s    *+6
  317.         move    (a2)+,d0
  318.         addx    d0,d0
  319.         addx    d1,d1
  320.         dbf    d4,lzd_l4
  321.  
  322.         cmp    d5,d2
  323.         blo.s    lzd_naeman
  324.         moveq    #0,d2
  325. lzd_loop5:    moveq    #0,d3
  326.  
  327.         moveq    #2,d4
  328. lzd_l5:        add    d0,d0
  329.         bne.s    *+6
  330.         move    (a2)+,d0
  331.         addx    d0,d0
  332.         addx    d3,d3
  333.         dbf    d4,lzd_l5
  334.  
  335.         add.l    d3,d2
  336.         cmp    d6,d3
  337.         beq.s    lzd_loop5
  338.  
  339. lzd_naeman:    addq.l    #2,d2
  340.         move.l    a0,a1
  341.         sub    d1,a1
  342. lzd_loop8:    move.b    (a1)+,(a0)+
  343.         subq.l    #1,d2
  344.         bpl.s    lzd_loop8
  345.  
  346. lzd_test:    cmp.l    a3,a0
  347.         blo    lzd_ympari_mennaan_yhteen_tullaan
  348.         moveq    #0,d0            ;decrunched ok
  349.         rts
  350.